package com.qianfeng.openapi.web.master.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qianfeng.openapi.web.master.mapper.UserTokenMapper;
import com.qianfeng.openapi.web.master.pojo.UserToken;
import com.qianfeng.openapi.web.master.service.UserTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author LJF
 * @Date 2020/7/3 11:30
 * @Version 1.0
 */
@Service
@Transactional
public class UserTokenServiceImpl implements UserTokenService {

    @Autowired
    private UserTokenMapper userTokenMapper;

    @Override
    public int insertUserToken(UserToken UserToken) {
        return userTokenMapper.insertUserToken(UserToken);
    }

    @Override
    public int updateUserToken(UserToken UserToken) {
        return userTokenMapper.updateUserToken(UserToken);
    }

    @Override
    public int deleteUserToken(Integer id) {
        return userTokenMapper.deleteUserToken(id);
    }

    @Override
    public void deleteUserTokens(Integer[] ids) {
        userTokenMapper.deleteUserTokens(ids);
    }

    @Override
    public UserToken getUserTokenById(Integer id) {
        return userTokenMapper.getUserTokenById(id);
    }

    @Override
    public List<UserToken> getAllUserTokens() {
        return null;
    }

    @Override
    public PageInfo<UserToken> getUserTokenByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<UserToken> userTokenList = userTokenMapper.getAllUserTokens();
        return new PageInfo<>(userTokenList);
    }



    @Override
    public PageInfo<UserToken> selectUserTokenByCondition(Integer page, Integer limit, Integer appId, Integer userId, String access_token) {
        PageHelper.startPage(page,limit);
        List<UserToken> userTokenList = userTokenMapper.selectUserTokenByCondition(appId,userId,access_token);
        return new PageInfo<>(userTokenList);
    }
}
